<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html style="overflow:hidden">
<head>
    <meta charset="gbk"/>
    <link rel="stylesheet" type="text/css" href="http://a.tbcdn.cn/tbsp/tbsp.css?t=20090602.css"/>
    <link rel="stylesheet" type="text/css" href="http://a.tbcdn.cn/tbsp/global_nav.css?t=200910151035.css"/>
    <script type="text/javascript" src="http://a.tbcdn.cn/tbra/1.0/tbra-widgets.js?t=20090619.js"></script>
    <link rel="stylesheet" type="text/css"
          href="http://a.tbcdn.cn/app/c2c/charging_center/charging_center.css?t=200910151035.css"/>
    <script type="text/javascript"
            src="http://a.tbcdn.cn/app/c2c/charging_center/charging_center.js?t=201001061543201.js"></script>
    <title>充话费-充值中心</title>
</head>

<body class="telephone">
<script type="text/javascript">
    (function () {
        function atrand(num) {
            return Math.floor(Math.random() * num) + 1
        }

        var P = location.pathname;
        if ((parent === self) || P.indexOf('/list_forum') != -1 || P.indexOf('/theme/info/info') != -1 || P.indexOf('/promo/co_header.php') != -1 || P.indexOf('fast_buy.htm') != -1 || P.indexOf('/add_collection.htm') != -1) {
            var R = escape(document.referrer);
            document.write('<img src="http://www.atpanel.com/1.gif?cache=' + atrand(9999999) + '&pre=' + R + '&scr=' + screen.width + 'x' + screen.height + '&category=&userid=&channel=112&ad_id=" width="0" height="0" style="display:none;" />')
        }
    })();
</script>

<script type="text/javascript">
    (function () {
        function akrand(num) {
            return Math.floor(Math.random() * num) + 1
        }

        var P = location.pathname;
        if ((parent === self) || P.indexOf('/list_forum') != -1 || P.indexOf('/theme/info/info') != -1 || P.indexOf('/promo/co_header.php') != -1 || P.indexOf('fast_buy.htm') != -1 || P.indexOf('/add_collection.htm') != -1) {
            var R = escape(document.referrer);
            var acookie_load_id = "" + akrand(9999999999) + akrand(9999999999);
            var isv_title = escape(document.title);
            document.write('<img src="http://acookie.taobao.com/1.gif?acookie_load_id=' + acookie_load_id + '&title=' + isv_title + '&pre=' + R + '&category=&userid=&channel=112&ad_id=" width="0" height="0" style="display:none;" />')
        }
    })();
</script>

<form id="J_FormTelephone" class=" formone " method="post" action="http://buy.taobao.com/auction/buy_now.htm"
      target="_blank">
    <table class="form-table" border="0" cellspacing="0" cellpadding="0">
        <tbody>
        <TR>
            <TD colspan="2" class="tel-img-box"><img
                    src="http://img08.taobaocdn.com/tps/i8/T1PJBzXc8GXXXXXXXX-295-19.png" title="安全、快捷、方便"
                    alt="安全、快捷、方便"/></TD>
        </TR>
        <tr>
            <th scope="row" class="tel-num"><label>物联卡号：</label></th>
            <td>
                <div id="J_TelInputBox" class="feild-box tel-input-box">
                    <div class="tel-input-wrap"><label class="tel-input-label"><input id="J_TelInput" class="tel-input"
                                                                                      maxlength="12" autocomplete="off"
                                                                                      name="phone" type="text"
                                                                                      title="支持移动联通电信"><a
                            id="J_TelInputIcon" class="tel-input-icon" href="#">查看最近输入的号码</a></label></div>
                    <div id="J_SelectZone" class=" hidden">
                        <label>所属：<select id="J_TelZone" name="">
                            <option selected="selected" value="">请选择</option>
                            <option value="浙江">浙江</option>
                            <option value="上海">上海</option>
                            <option value="北京">北京</option>
                            <option value="广东">广东</option>
                            <option value="江苏">江苏</option>
                            <option value="安徽">安徽</option>
                            <option value="重庆">重庆</option>
                            <option value="福建">福建</option>
                            <option value="甘肃">甘肃</option>
                            <option value="广西">广西</option>
                            <option value="贵州">贵州</option>
                            <option value="河北">河北</option>
                            <option value="湖北">湖北</option>
                            <option value="黑龙江">黑龙江</option>
                            <option value="海南">海南</option>
                            <option value="河南">河南</option>
                            <option value="湖南">湖南</option>
                            <option value="吉林">吉林</option>
                            <option value="江西">江西</option>
                            <option value="辽宁">辽宁</option>
                            <option value="内蒙古">内蒙古</option>
                            <option value="宁夏">宁夏</option>
                            <option value="青海">青海</option>
                            <option value="四川">四川</option>
                            <option value="山东">山东</option>
                            <option value="山西">山西</option>
                            <option value="陕西">陕西</option>
                            <option value="天津">天津</option>
                            <option value="新疆">新疆</option>
                            <option value="西藏">西藏</option>
                            <option value="云南">云南</option>
                        </select>
                        </label>
                        <label>运营商：<select id="J_TelISP" name="">
                            <option selected="selected" value="">请选择</option>
                            <option value="150401">移动</option>
                            <option value="150402">联通</option>
                            <option value="50011814">电信/CDMA</option>
                        </select>
                        </label>
                    </div>
                    <p id="J_Msg" class=" h hidden"></p>
                    <p id="J_BelongResult" class="hidden">所属：<span id="J_Belong">浙江移动</span>（<a id="J_BelongModifyLink"
                                                                                                href="#">不是浙江移动？</a>）
                    </p>
                </div>
            </td>
        </tr>
        <tr>
            <th scope="row"><label>充值方式：</label></th>
            <td>
                <div class="feild-box">
                    <div id="J_MethodBox" class="method">
                        <label for="J_MethodRadioEcard"><input id="J_MethodRadioEcard" class="J_MethodRadio" name="a"
                                                               type="radio" value="" checked="checked">自动充值<span>（1-10分钟充值到帐）</span></label>
                        <label for="J_MethodRadioFill"><input id="J_MethodRadioFill" class="J_MethodRadio" name="a"
                                                              type="radio" value="">卖家代充<span>（2小时充值到帐）</span></label>
                        <label for="J_MethodRadioAutoPost"><input id="J_MethodRadioAutoPost" class="J_MethodRadio"
                                                                  name="a" type="radio"
                                                                  value="">自动发货<span>（提取卡密手动充值）</span></label>
                    </div>
                    <a id="J_MoreMethodTrigger" href="#">其他充值方式</a>
                </div>
            </td>
        </tr>
        <tr>
            <th scope="row"><label>面额：</label></th>
            <td>
                <div id="J_DenominationBox" class="feild-box denomination">
                    <!-- modified by mbn 加入input的值，以供取pidvid判断 start-->
                    <label for="J_Denomination100"><input id="J_Denomination100" class="J_DenominationRadio" name="b"
                                                          type="radio" value="100" checked="checked">100元</label>
                    <label for="J_Denomination50"><input id="J_Denomination50" class="J_DenominationRadio" name="b"
                                                         type="radio" value="50">50元</label>
                    <label for="J_DenominationElse" class="other"><input id="J_DenominationElse"
                                                                         class="J_DenominationRadio" name="b"
                                                                         type="radio" value="-1">其他</label>
                    <!-- modified by mbn 加入input的值，以供取pidvid判断 end-->
                    <!-- modified by mbn 修改默认的其他面值为移动的面值 start-->
                    <select id="J_DenominationSelect" name="">
                        <option value="1">1元</option>
                        <option value="10">10元</option>
                        <option value="20">20元</option>
                        <option value="30" selected>30元</option>
                        <option value="200">200元</option>
                        <option value="300">300元</option>
                        <option value="500">500元</option>
                        <option value="1000">1000元</option>
                    </select>
                    <!-- modified by mbn 修改默认的其他面值为移动的面值 end-->
                </div>
            </td>
        </tr>
        <tr>
            <th scope="row"><label id="J_PriceLabel">价格：</label></th>
            <td>
                <div class="feild-box">
                    <strong id="J_Price" class="price">98元-99.6元</strong>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button type="submit" class="btn-submit" id="J_SubmitButton">点此充值</button>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a target="_blank"
                                                 href="http://www.taobao.com/go/act/wap/act-zc-regularly.php">new!开通定期充值</a>
            </td>

        </tr>
        </tbody>
    </table>
    <input type="hidden" id="J_BuyAuction" name="action" value="buynow/PhoneEcardBuyNowAction">
    <input type="hidden" name="event_submit_do_buy" value="1">
    <input type="hidden" name="item_id_num" value="">
    <input type="hidden" name="x_id" value="0db2">
    <input type="hidden" id="suoshu" name="suoshu" value="">
    <input type="hidden" id="telString" name="telString" value="">
    <input type="hidden" id="type" name="type" value="">
    <input name='_tb_token_' type='hidden' value='e3e93e57e77ee'>
</form>
<script>
    YAHOO.util.Event.onDOMReady(function () {
        var Util = YAHOO.util, Dom = Util.Dom, Event = Util.Event, Lang = Util.Lang;
        var telInput = Dom.get('J_TelInput');
        //输入框默认显示文字提示
        var telInputTips = telInput.title;
        telInput.removeAttribute('title');
        telInput.value = telInputTips;
        telInput.style.color = '#808080';
        //切换输入框的提示显示
        Event.on(telInput, 'click', function () {
            if (telInput.value == telInputTips) {
                telInput.value = '';
                telInput.style.color = '#404040';
            }
        });
        Event.on(telInput, 'focus', function () {
            if (telInput.value == telInputTips) {
                telInput.value = '';
                telInput.style.color = '#404040';
            }
        });
        Event.on(telInput, 'blur', function () {
            if (Lang.trim(telInput.value) == '') {
                telInput.value = telInputTips;
                telInput.style.color = '#808080';
            }
        });

        //前端校验输入的电话号码是否合格
        var telInputBox = Dom.get('J_TelInputBox');
        var selectZone = Dom.get('J_SelectZone');
        var msgBox = Dom.get('J_Msg');
        var belongResult = Dom.get('J_BelongResult');
        var belong = Dom.get('J_Belong');
        var belongModifyLink = Dom.get('J_BelongModifyLink');
        var validateResultPanelArr = [selectZone, msgBox, belongResult];
        var telZoneSelect = Dom.get('J_TelZone');
        var telISPSelect = Dom.get('J_TelISP');

        /**
         *设置选择运营商是否只有电信可用
         * @param {Boolean} [ifOnlyCTSelectable=false] 设置运营商是否只有电信可选
         */
        function setISPOptionState(ifOnlyCTSelectable) {
            var ISPOptionArr = telISPSelect.getElementsByTagName('option');
            if (ifOnlyCTSelectable) {
                for (var i = 0, len = ISPOptionArr.length; i < len; i++) {
                    if (ISPOptionArr[i].innerHTML.indexOf('电信') < 0 && ISPOptionArr[i].innerHTML.indexOf('选择') < 0) ISPOptionArr[i].disabled = true;
                }
            } else {
                for (var i = 0, len = ISPOptionArr.length; i < len; i++) {
                    ISPOptionArr[i].disabled = false;
                }
            }
        }

        //去服务器端取号码归属地的信息
        function getTelInfo() {
            YAHOO.util.Get.script(
                'http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=' + telInput.value,
                {
                    onSuccess: function () {
                        var result = __GetZoneResult_;
                        if (result.catName && result.catName.indexOf('电信') >= 0) {
                            result.catName = '电信';
                        } else if (result.catName && result.catName.indexOf('移动') >= 0) {
                            result.catName = '移动';
                        } else if (result.catName && result.catName.indexOf('联通') >= 0) {
                            result.catName = '联通';
                        }

                        //埋点log
                        var suoshu = Dom.get('suoshu');
                        var type = Dom.get('type');
                        var telString = Dom.get('telString');
                        suoshu.value = result.province;
                        type.value = result.catName;
                        telString.value = result.telString;


                        //如果请求的是固话的
                        if (telInput.value.substr(0, 1) == '0') {
                            setISPOptionState(true);
                            //如果返回的省信息不成功，默认设置北京
                            if (result.province == '') {
                                setSelectValue(telZoneSelect, 'innerHTML', '北京');
                            } else {
                                setSelectValue(telZoneSelect, 'innerHTML', result.province);
                            }
                            setSelectValue(telISPSelect, 'innerHTML', '电信/CDMA');
                        } else {
                            //如果请求的是手机号码且查询成功的
                            if (result.mts) {
                                showPanel(belongResult);
                                setSelectValue(telZoneSelect, 'innerHTML', result.province);
                                if (result.catName == '电信') {
                                    setSelectValue(telISPSelect, 'innerHTML', '电信/CDMA');
                                } else {
                                    setSelectValue(telISPSelect, 'innerHTML', result.catName);
                                }
                                belong.innerHTML = result.province + result.catName;
                                belongModifyLink.innerHTML = '不是' + result.province + result.catName;
                                //如果手机号码查询不成功，仅返回地区
                            } else {
                                setSelectValue(telZoneSelect, 'innerHTML', '请选择');
                                setSelectValue(telISPSelect, 'innerHTML', '请选择');
                                //如果ip也查询不成功，默认省信息为移动
                                if (result.province == '') {
                                    //setSelectValue(telZoneSelect,'innerHTML','浙江');
                                    //setSelectValue(telISPSelect,'innerHTML','移动');
                                    Dom.addClass(Dom.get('J_SubmitButton'), 'active');
                                } else {
                                    //setSelectValue(telZoneSelect,'innerHTML',result.province);
                                }
                            }
                        }
                        // add by mbn 请求成功刷新一次价格 start
                        if (isPriceEnoughCondition()) {
                            getPriceInfo();
                        } else {
                            getPriceZoneInfo();
                        }
                        // add by mbn 请求成功刷新一次价格 end
                    },
                    charset: document.charset || document.characterSet
                }
            );
        }

        //modified by mbn 修改了正则表达式 手机以1开头，长度11位 start
        //增加固话表达式，以0开头，长度9到12位

        //中国移动手机号表达式
        CMCCPhoneNumberPattern = /^1\d{10}$/;
        //中国联通手机号表达式
        CUCPhoneNumberPattern = /^1\d{10}$/;
        //固话表达式
        CommonPhoneNumberPattern = /^0\d{8,11}$/;

        //modified by mbn 修改了正则表达式 end

        /**
         *设置select的指定项为选中状态
         * param {HTMLElement} selectEl 要设置的select元素
         * param {String} attribute 根据select的该属性来判定哪个option被选中，接受两个值'value'和'innerHTML'
         * param {String} value 被选中的option的指定属性对应的值
         */
        function setSelectValue(selectEl, attribute, value) {
            if (attribute == 'value') {
                selectEl.value = value;
            } else {
                var optionArr = selectEl.getElementsByTagName('option');
                for (var i = 0, len = optionArr.length; i < len; i++) {
                    if (optionArr[i].innerHTML == value) {
                        selectEl.value = optionArr[i].value;
                        break;
                    }
                }
            }
        }

        //校验出错时，高亮输入框区域
        function highlightTelInputBox(param) {
            if (param) {
                telInputBox.style.background = '#ffdbbe';
            } else {
                telInputBox.style.background = 'transparent';
            }
        }

        //根据校验结果显示指定面板
        function showPanel(el) {
            Dom.addClass(validateResultPanelArr, 'hidden');
            if (el) Dom.removeClass(el, 'hidden');
            if (el == selectZone) {
                setISPOptionState();
                if (Dom.get('J_AdNewLink')) {
                    Dom.get('J_AdNewLink').style.display = "none";
                }
            }

        }

        //有键盘输入时校验输入的电话号码（这并非是全部的校验逻辑，电话号码是否足位的校验将在提交的时候校验）
        function validateTel() {
            highlightTelInputBox(true);
            var val = telInput.value;

            //如果有输入非数字
            if (!val.match(/^[0-9]*$/)) {
                highlightTelInputBox(true);
                showPanel(msgBox);
                msgBox.innerHTML = '手机或固话号码仅由数字组成';
                telInput.value = val.substr(0, val.length - 1);
                //如果输入号码首位是0，则为固话号码
            } else {
                //如果是固话（以0开头的）
                if (val.substr(0, 1) == '0') {
                    telInput.maxLength = '12'
                    highlightTelInputBox(false);
                    //只有在选择地区和运营商的下拉框不显示的时候才去获取地区信息，避免重复请求（这种情况下还是有遗漏，比如用户输入一个11位的手机号，再在手机号前加个0，就不会触发这个请求，但这种情况可以不予考虑）
                    if (Dom.hasClass(selectZone, 'hidden')) {
                        showPanel(selectZone);
                        getTelInfo();
                    }
                    //如果是手机
                } else {
                    telInput.maxLength = '11';
                    showPanel();
                    if (val.length > 11) {
                        telInput.value = val.substr(0, 11);
                    }
                    val = telInput.value;
                    //如果手机号码输入到11位，且通过移动或者联通号码格式的校验
                    if (val.length == 11) {
                        if (val.match(CMCCPhoneNumberPattern) || val.match(CUCPhoneNumberPattern)) {
                            highlightTelInputBox(false);
                            showPanel(selectZone);
                            //手机号码通过验证时才去获取地区信息
                            getTelInfo();

                            //add by mbn

                        } else {
                            highlightTelInputBox(true);
                            showPanel(msgBox);
                            msgBox.innerHTML = '请输入正确的物联卡号';
                        }
                    } else {
                        showPanel();
                        highlightTelInputBox(false);
                    }
                }
                ;
            }
            if (val == '') {
                getPriceZoneInfo();
            }
        }

        Event.on(telInput, 'keyup', validateTel);

        //获取手机号码信息成功后，给用户自行修改的链接
        Event.on(belongModifyLink, 'click', function (ev) {
            Event.stopEvent(ev);
            showPanel(selectZone);
        })

        //显示更多充值方式
        var methodBox = Dom.get('J_MethodBox');
        var moreMethodTrigger = Dom.get('J_MoreMethodTrigger');
        Event.on(moreMethodTrigger, 'click', function (e) {
            Event.preventDefault(e);
            methodBox.style.height = 'auto';
            this.style.display = 'none';
        });
        //高亮选中的面额
        var denominationRadioArr = Dom.get('J_DenominationBox').getElementsByTagName('label');
        for (var i = 0, len = denominationRadioArr.length; i < len; i++) {
            if (denominationRadioArr[i].getElementsByTagName('input')[0].checked) {
                Dom.addClass(denominationRadioArr[i], 'selected');
                break;
            }
        }
        Event.on(denominationRadioArr, 'click', function (e) {
            Dom.removeClass(denominationRadioArr, 'selected');
            Dom.addClass(this, 'selected');
            var t = Event.getTarget(e);
            if (t.nodeName.toLowerCase() == 'input') {
                // add by mbn 高亮的同时刷新价格或价格区间 start
                if (isPriceEnoughCondition()) {
                    getPriceInfo();
                } else {
                    getPriceZoneInfo();
                }
                // add by mbn 高亮的同时刷新价格或价格区间 end
            }
        });

        //初始化flash本地存储
        flashStorage.init();

        //将通过验证提交的号码添加到本地存储，存储最近5个号码
        function addTelToStorage(tel) {
            flashStorage.read('latestTelNum', function (val) {
                if (!val || val.length <= 0) {
                    flashStorage.save('latestTelNum', tel);
                } else {
                    var telNumArr = val.split(',');
                    if (val.indexOf(tel) < 0) {
                        if (telNumArr.length >= 3) {
                            telNumArr.shift();
                        }
                    } else {
                        for (var i = 0, len = telNumArr.length; i < len; i++) {
                            if (tel == telNumArr[i]) {
                                telNumArr.splice(i, 1);
                                break;
                            }
                        }
                    }
                    telNumArr[telNumArr.length] = tel;
                    flashStorage.save('latestTelNum', telNumArr.toString());
                }
            });
        }

        var telInputIcon = Dom.get('J_TelInputIcon');
        var telInput = Dom.get('J_TelInput');
        //如果有存储最近充值的号码，则激活号码输入框旁边的按钮
        flashStorage.read('latestTelNum', function (val) {
            if (val && val.length > 0) {
                Dom.addClass(telInputIcon, "has-latest-input");
                var telNumArr = val.split(',');
                var telNumList = document.createElement('div');
                Event.onDOMReady(function () {
                    document.body.appendChild(telNumList);
                });
                telNumList.style.display = 'none';
                telNumList.className = 'tel-num-list';
                var inner = '';
                inner += '<iframe scrolling="no" frameborder="0" style="width:100%;height:' + telNumArr.length * 30 + 'px;position:absolute"></iframe><div style="position:relative">';
                for (var len = telNumArr.length, i = len - 1; i >= 0; i--) {
                    if (i == len - 1) {
                        //add by mbn 20100318 号码输入框显示最近输入的一个号码，并刷新价格 start
                        telInput.value = telNumArr[i];
                        validateTel();
                        //add by mbn 20100318 end
                        inner += '<a href="#" class="first">' + telNumArr[i] + '</a>'
                    } else {
                        inner += '<a href="#">' + telNumArr[i] + '</a>'
                    }
                }
                if (Dom.get('J_AdNewLink')) {
                    Dom.get('J_AdNewLink').style.display = "block";
                }
                inner += '</div>';
                telNumList.innerHTML = inner;
                var popupOffset = YAHOO.env.ua.ie == 6 ? [-41, -2] : [-40, 0];
                TB.widget.SimplePopup.decorate(telInputIcon, telNumList, {
                    position: 'bottom',
                    align: 'right',
                    offset: popupOffset
                });
                Event.on(telNumList, 'click', function (e) {
                    Event.stopEvent(e);
                    var t = Event.getTarget(e);
                    if (t.nodeName.toLowerCase() == 'a') {
                        telInput.value = t.innerHTML;
                        telNumList.style.display = 'none';
                        //add by mbn 20100318 刷新价格 start
                        validateTel();
                        //add by mbn 20100318 end
                    }
                });
            }
        });

        var act = "",
            hasLogin = false,//[false],
            roper = "";//


        //提交前验证号码是否足位
        Event.on('J_FormTelephone', 'submit', function (e) {
            var val = telInput.value;
            var itemId = formTelephone['item_id_num'].value;
            if (!(val.match(CMCCPhoneNumberPattern) || val.match(CUCPhoneNumberPattern) || val.match(CommonPhoneNumberPattern))) {
                Event.preventDefault(e);
                highlightTelInputBox(true);
                showPanel(msgBox);
                msgBox.innerHTML = '号码错误，如需充固话请添加区号。';
            } else if (!validateItemId(itemId)) {
                Event.preventDefault(e);
                Dom.removeClass(msgBox, 'hidden');
                msgBox.innerHTML = '请选择归属地';
            } else {
                //modified by mbn 20100322 只有直冲带auction参数，其他不带
                //获得充值方式，不同的充值方式url参数不一样
                var method = getMethodSelected();
                if (method == 0) {
                    buyAuction.name = 'action';
                } else {
                    buyAuction.name = 'noaction';
                }
                addTelToStorage(val);
                tloadAt(2);
            }
            if (typeof act !== 'undefined' && act === 'hb') {
                if (hasLogin) {
                    document.createElement('img').src = 'http://promotion.taobao.com/recharge/saveRope.do?roper=' + roper;
                } else {
                    Event.stopEvent(e);
                    top.location.href = 'https://login.taobao.com/member/login.jhtml?redirectURL=http%3A%2F%2Fwww.taobao.com%2Fgo%2Fact%2Fsale%2Fbwdj.php%3Froper%3D' + roper;
                }
            }

        });

        <!------------------------------------------------------------20100311add by 缪柏年 start-->

        //埋点函数
        function tloadAt(pmid) {
            var cImg = document.createElement('img');
            if (pmid == 1) {
                cImg.src = "http://ju.atpanel.com/?url=http://www.atpanel.com?ad_id=&am_id=&cm_id=&pm_id=15002232708f914483f8";
            } else {
                cImg.src = "http://ju.atpanel.com/?url=http://www.atpanel.com?ad_id=&am_id=&cm_id=&pm_id=15002232562ccd5542ca";
            }
            return true;
        }

        function nloadAt(pmid) {
            var cImg = document.createElement('img');
            if (pmid) {
                cImg.src = "http://www.atpanel.com/jsclick?cache=" + (Math.floor(Math.random() * 99999) + 1) + "&xfzhyj=" + pmid;
            }
            return true;
        }

        function StringBuffer() {
            this._strings_ = new Array();
        }

        StringBuffer.prototype.append = function (str) {
            this._strings_.push(str);
        }

        StringBuffer.prototype.toString = function () {
            return this._strings_.join("");
        }

        //form对象
        var formTelephone = Dom.get('J_FormTelephone');
        //其他面值
        var denominationSelect = Dom.get('J_DenominationSelect');
        //价格
        var priceSelect = Dom.get('J_Price');
        //价格label
        var priceLabel = Dom.get('J_PriceLabel');
        //面值区域box
        var denominationBox = Dom.get('J_DenominationBox');
        //充值方式box
        var methodBox = Dom.get('J_MethodBox');
        //点此充值按钮
        var submitButton = Dom.get('J_SubmitButton');
        //buy的auction参数隐藏域
        var buyAuction = Dom.get('J_BuyAuction');


        var CatProps = function () {
        };
        var catProps = new CatProps();
        catProps['150401'] = ['20780', '20779', '20789'];
        catProps['150402'] = ['20782', '20781', '20790'];
        catProps['50011814'] = ['1626918', '1626917', '1626919'];


        var CatReserve = function () {
        };
        var catReserve = new CatReserve();
        catReserve['150401'] = [1, 10, 20, 30, 200, 300, 500, 1000];
        catReserve['150402'] = [1, 10, 20, 30, 133, 200, 300, 500];
        catReserve['50011814'] = [1, 10, 20, 30, 200, 300, 500, 1000];
        catReserve['personnal'] = [1, 10, 20, 30, 200, 300, 500];

        var ecardPrice = {
            '1': '30675',
            '10': '30676',
            '20': '30677',
            '30': '30688',
            '50': '30678',
            '100': '30679',
            '200': '30690',
            '300': '30691',
            '500': '30692',
            '1000': '38182',
            '其它面值': '30689'
        }

        var areaLocations = {
            '全国通用': '30680',
            '北京': '29400',
            '天津': '29428',
            '内蒙古': '30495',
            '黑龙江': '30496',
            '吉林': '30497',
            '辽宁': '30498',
            '河北': '30499',
            '河南': '30500',
            '山东': '30501',
            '山西': '30502',
            '陕西': '30503',
            '青海': '30504',
            '甘肃': '30505',
            '新疆': '30506',
            '西藏': '27009',
            '宁夏': '30507',
            '重庆': '29404',
            '四川': '30508',
            '安徽': '30509',
            '上海': '29423',
            '浙江': '30510',
            '江苏': '30511',
            '江西': '30512',
            '湖北': '30513',
            '湖南': '30514',
            '云南': '30515',
            '贵州': '30516',
            '广东': '30517',
            '广西': '30518',
            '福建': '30519',
            '台湾': '27368',
            '香港': '27369',
            '澳门': '29121',
            '海南': '30520',
            '其他地区': '30681'
        }

        var gFilters = new Array();
        gFilters['150401-auto_ship-10'] = '[10,12]';
        gFilters['150401-auto_ship-20'] = '[19.6,23]';
        gFilters['150401-auto_ship-30'] = '[29.5,32]';
        gFilters['150401-auto_ship-50'] = '[49.05,50]';
        gFilters['150401-auto_ship-100'] = '[98.1,100]';
        gFilters['150401-auto_ship-200'] = '[196.4,200]';
        gFilters['150401-auto_ship-300'] = '[294.6,300]';
        gFilters['150401-auto_ship-500'] = '[490,500]';
        gFilters['150401-auto_ship-1000'] = '[984,1000]';
        gFilters['150401-delegator_fill_72H-1'] = '[1.2,2]';
        gFilters['150401-delegator_fill_72H-10'] = '[9.85,12]';
        gFilters['150401-delegator_fill_72H-20'] = '[19.7,22]';
        gFilters['150401-delegator_fill_72H-30'] = '[29.55,31]';
        gFilters['150401-delegator_fill_72H-50'] = '[48,50]';
        gFilters['150401-delegator_fill_72H-100'] = '[96,100]';
        gFilters['150401-delegator_fill_72H-200'] = '[192,200]';
        gFilters['150401-delegator_fill_72H-300'] = '[288,300]';
        gFilters['150401-delegator_fill_72H-500'] = '[480,500]';
        gFilters['150401-delegator_fill_72H-1000'] = '[984,1000]';
        gFilters['150401-delegator_fill_10M-1'] = '[1.2,2]';
        gFilters['150401-delegator_fill_10M-10'] = '[9.9,12]';
        gFilters['150401-delegator_fill_10M-20'] = '[20,23]';
        gFilters['150401-delegator_fill_10M-30'] = '[29.5,32]';
        gFilters['150401-delegator_fill_10M-50'] = '[49,50]';
        gFilters['150401-delegator_fill_10M-100'] = '[98,100]';
        gFilters['150401-delegator_fill_10M-200'] = '[196.4,200]';
        gFilters['150401-delegator_fill_10M-300'] = '[294.6,300]';
        gFilters['150401-delegator_fill_10M-500'] = '[490,500]';
        gFilters['150401-delegator_fill_10M-1000'] = '[984,1000]';
        gFilters['150401-ecard_item-10'] = '[10,10.6]';
        gFilters['150401-ecard_item-20'] = '[20,20.8]';
        gFilters['150401-ecard_item-30'] = '[30.5,30.5]';
        gFilters['150401-ecard_item-50'] = '[49.7,49.9]';
        gFilters['150401-ecard_item-100'] = '[99.4,99.5]';
        gFilters['150401-ecard_item-200'] = '[199.5,199.5]';
        gFilters['150401-ecard_item-300'] = '[299.3,299.3]';
        gFilters['150401-ecard_item-500'] = '[498.9,498.9]';


        gFilters['150402-auto_ship-1'] = '[1.35,2]';
        gFilters['150402-auto_ship-10'] = '[9.7,12]';
        gFilters['150402-auto_ship-20'] = '[19.4,23]';
        gFilters['150402-auto_ship-30'] = '[29.4,32]';
        gFilters['150402-auto_ship-50'] = '[49.05,50]';
        gFilters['150402-auto_ship-100'] = '[98.1,100]';
        gFilters['150402-auto_ship-133'] = '[130,135]';
        gFilters['150402-auto_ship-200'] = '[196.4,200]';
        gFilters['150402-auto_ship-300'] = '[294.6,300]';
        gFilters['150402-auto_ship-500'] = '[490,500]';
        gFilters['150402-auto_ship-1000'] = '[984,1000]';
        gFilters['150402-delegator_fill_10M-1'] = '[1.2,2]';
        gFilters['150402-delegator_fill_10M-10'] = '[9.7,12]';
        gFilters['150402-delegator_fill_10M-20'] = '[19.4,23]';
        gFilters['150402-delegator_fill_10M-30'] = '[29.4,32]';
        gFilters['150402-delegator_fill_10M-50'] = '[49]';
        gFilters['150402-delegator_fill_10M-100'] = '[98]';
        gFilters['150402-delegator_fill_10M-133'] = '[130,135]';
        gFilters['150402-delegator_fill_10M-200'] = '[196.4,200]';
        gFilters['150402-delegator_fill_10M-300'] = '[294.6,300]';
        gFilters['150402-delegator_fill_10M-500'] = '[490,500]';
        gFilters['150402-delegator_fill_10M-1000'] = '[984,1000]';
        gFilters['150402-delegator_fill_72H-1'] = '[1.2,2]';
        gFilters['150402-delegator_fill_72H-10'] = '[9.6,13]';
        gFilters['150402-delegator_fill_72H-20'] = '[19.2,22]';
        gFilters['150402-delegator_fill_72H-30'] = '[29,31]';
        gFilters['150402-delegator_fill_72H-50'] = '[47.75,50]';
        gFilters['150402-delegator_fill_72H-100'] = '[95.5,100]';
        gFilters['150402-delegator_fill_72H-133'] = '[128,135]';
        gFilters['150402-delegator_fill_72H-200'] = '[191,200]';
        gFilters['150402-delegator_fill_72H-300'] = '[287,300]';
        gFilters['150402-delegator_fill_72H-500'] = '[479,500]';
        gFilters['150402-delegator_fill_72H-1000'] = '[984,1000]';
        gFilters['150402-ecard_item-20'] = '[20,21.5]';
        gFilters['150402-ecard_item-30'] = '[30,31.5]';
        gFilters['150402-ecard_item-50'] = '[49.15,49.6]';
        gFilters['150402-ecard_item-100'] = '[99.1,99.6]';
        gFilters['150402-ecard_item-200'] = '[199,199]';

        gFilters['50011814-auto_ship-10'] = '[10,12]';
        gFilters['50011814-auto_ship-20'] = '[19.6,23]';
        gFilters['50011814-auto_ship-30'] = '[29.5,32]';
        gFilters['50011814-auto_ship-50'] = '[49.05,50]';
        gFilters['50011814-auto_ship-100'] = '[98.1,100]';
        gFilters['50011814-auto_ship-200'] = '[196.4,200]';
        gFilters['50011814-auto_ship-300'] = '[294.6,300]';
        gFilters['50011814-auto_ship-500'] = '[490,500]';
        gFilters['50011814-auto_ship-1000'] = '[984,1000]';
        gFilters['50011814-delegator_fill_72H-1'] = '[1.2,2]';
        gFilters['50011814-delegator_fill_72H-10'] = '[9.85,12]';
        gFilters['50011814-delegator_fill_72H-20'] = '[19.7,22]';
        gFilters['50011814-delegator_fill_72H-30'] = '[29.55,31]';
        gFilters['50011814-delegator_fill_72H-50'] = '[48,50]';
        gFilters['50011814-delegator_fill_72H-100'] = '[96,100]';
        gFilters['50011814-delegator_fill_72H-200'] = '[192,200]';
        gFilters['50011814-delegator_fill_72H-300'] = '[288,300]';
        gFilters['50011814-delegator_fill_72H-500'] = '[480,500]';
        gFilters['50011814-delegator_fill_72H-1000'] = '[984,1000]';
        gFilters['50011814-delegator_fill_10M-1'] = '[1.2,2]';
        gFilters['50011814-delegator_fill_10M-10'] = '[9.9,12]';
        gFilters['50011814-delegator_fill_10M-20'] = '[20,23]';
        gFilters['50011814-delegator_fill_10M-30'] = '[29.5,32]';
        gFilters['50011814-delegator_fill_10M-50'] = '[49,50]';
        gFilters['50011814-delegator_fill_10M-100'] = '[98,100]';
        gFilters['50011814-delegator_fill_10M-200'] = '[196.4,200]';
        gFilters['50011814-delegator_fill_10M-300'] = '[294.6,300]';
        gFilters['50011814-delegator_fill_10M-500'] = '[490,500]';
        gFilters['50011814-delegator_fill_10M-1000'] = '[984,1000]';

        gFilters['50011814-ecard_item-20'] = '[19.84,19.96]';
        gFilters['50011814-ecard_item-20'] = '[29.58,29.76]';
        gFilters['50011814-ecard_item-20'] = '[49.3,49.8]';
        gFilters['50011814-ecard_item-20'] = '[98,99.6]';

        gFilters['common-ecard_item-1'] = '[0.98,1.5]';
        gFilters['common-ecard_item-10'] = '[10,10.6]';
        gFilters['common-ecard_item-20'] = '[19.84,20.8]';
        gFilters['common-ecard_item-30'] = '[29.58,31.5]';
        gFilters['common-ecard_item-50'] = '[49.3,49.9]';
        gFilters['common-ecard_item-100'] = '[98,99.6]';
        gFilters['common-ecard_item-133'] = '[130.3,131.6]';
        gFilters['common-ecard_item-200'] = '[199,199.5]';
        gFilters['common-ecard_item-300'] = '[299,299.3]';
        gFilters['common-ecard_item-500'] = '[498,498.9]';
        gFilters['common-ecard_item-1000'] = '[980,990]';

        gFilters['common-delegator_fill-1'] = '[0.98,1.5]';
        gFilters['common-delegator_fill-10'] = '[9.8,9.9]';
        gFilters['common-delegator_fill-20'] = '[19.6,20]';
        gFilters['common-delegator_fill-30'] = '[29.4,30]';
        gFilters['common-delegator_fill-50'] = '[49,49.8]';
        gFilters['common-delegator_fill-100'] = '[98,99.5]';
        gFilters['common-delegator_fill-133'] = '[130.3,131.6]';
        gFilters['common-delegator_fill-200'] = '[196,199]';
        gFilters['common-delegator_fill-300'] = '[294,299]';
        gFilters['common-delegator_fill-500'] = '[490,498]';
        gFilters['common-delegator_fill-1000'] = '[980,990]';

        gFilters['common-auto_post-1'] = '[0.98,1.5]';
        gFilters['common-auto_post-10'] = '[9.81,9.9]';
        gFilters['common-auto_post-20'] = '[19.62,21]';
        gFilters['common-auto_post-30'] = '[29.43,30]';
        gFilters['common-auto_post-50'] = '[49.05,49.8]';
        gFilters['common-auto_post-100'] = '[98.1,99.5]';
        gFilters['common-auto_post-133'] = '[130.3,131.6]';
        gFilters['common-auto_post-200'] = '[196.2,199]';
        gFilters['common-auto_post-300'] = '[294.3,299]';
        gFilters['common-auto_post-500'] = '[490.5,498]';
        gFilters['common-auto_post-1000'] = '[981,990]';

        function changeReserve() {
            var cat = telISPSelect.value;
            var r = denominationSelect;
            var or = r.value;
            if (catReserve[cat] == undefined || catReserve[cat] == null) {
                return;
            }
            var resetReserve = false;
            r.length = 0;
            for (var i = 0; i < catReserve[cat].length; i++) {
                r.options[i] = new Option(catReserve[cat][i] + '元', catReserve[cat][i]);
                if (catReserve[cat][i] == or) resetReserve = true;
            }
            if (resetReserve) r.value = or;
        }

        //获得选中的面额的值
        function getReservePrice() {
            var reservePrice = 100;
            var denominationRadioArr = denominationBox.getElementsByTagName('label');
            for (var i = 0, len = denominationRadioArr.length; i < len; i++) {
                var input = denominationRadioArr[i].getElementsByTagName('input')[0];
                if (input.checked) {
                    if (i < 2) {
                        reservePrice = input.value;
                    } else {
                        reservePrice = denominationSelect.value;
                    }
                    break;
                }
            }
            return reservePrice;
        }

        //获得选中的充值方式,返回0为直冲，1为代充，2为自动发货
        function getMethodSelected() {
            var methodRadioArr = methodBox.getElementsByTagName('label');
            for (var i = 0, len = methodRadioArr.length; i < len; i++) {
                var input = methodRadioArr[i].getElementsByTagName('input')[0];
                if (input.checked) {
                    return i;
                    break;
                }
            }
            return -1;
        }

        var rootUrl = 'http://tcc.taobao.com/cc/json/mobile_price.htm?';

        //获得请求服务器的url，包括根链接和参数
        function getPriceUrl() {
            //存放组装的参数
            var params = new StringBuffer();

            //获取所在地，面值，地区等
            var location = telZoneSelect.value;
            var reservePrice = getReservePrice();
            var catId = telISPSelect.value;

            //获取属性id属性值id
            var prop = catProps[catId];
            pidvid = prop[1] + ':' + ecardPrice[reservePrice] + ';' + prop[0] + ':' + areaLocations[location];


            //首先组装各种充值方式都必须的参数 start
            params.append('cat=' + catId);
            params.append('&ar=20');
            params.append('&commend=all');
            params.append('&sort=price');
            params.append('&reserve_price=' + reservePrice + '元');
            //首先组装各种充值方式都必须的参数 end


            //获得充值方式，不同的充值方式url参数不一样
            var method = getMethodSelected();

            if (method == 0) {//直冲
                params.append('&options=1099511627776');
                params.append('&search_type=ecard_auction');
            } else if (method == 1) {//代充
                params.append('&shippedType=卖家代充');
                params.append('&search_type=mobile_card');
                params.append('&atype=b');
                if (catId == 150401) {
                    pidvid = pidvid + ';' + prop[2] + ':' + 84923;
                } else {
                    pidvid = pidvid + ';' + prop[2] + ':' + 90682;
                }
                var filter = gFilters[catId + '-delegator_fill_10M-' + reservePrice];
                params.append('&filter=reserve_price');
                params.append(filter);
            } else if (method == 2) {//自动发货
                params.append('&search_type=mobile_card');
                params.append('&atype=b');
                params.append('&auto_post=1');
                params.append('&shippedType=自动发货');
                var filter = gFilters[catId + '-auto_ship-' + reservePrice];
                params.append('&filter=reserve_price');
                params.append(filter);

            }
            params.append('&pidvid=' + pidvid);
            //清缓存用
            var now = new Date();
            params.append('&randomJs=' + now.getTime() + '.js');

            //拼接请求服务器的url
            var url = rootUrl + params.toString();
            return url;
        }

        //在无法查询到商品宝贝或者查询失败或查询超时，输出 暂缺：点此充值
        function onGetPriceInfoError() {
            var toListHtml = new StringBuffer();
            toListHtml.append('<a href="http://list.taobao.com/browse/search_auction.htm?');
            //获取所在地，面值，地区等
            var location = telZoneSelect.value;
            var reservePrice = getReservePrice();
            var catId = telISPSelect.value;
            var prop = catProps[catId];
            toListHtml.append('cat=' + catId);
            toListHtml.append('&prop=&atype=b&commend=all&sort=bid&olu=yes');
            toListHtml.append('" target="_blank">点此搜索</a>');
            priceLabel.innerHTML = "暂缺：";
            priceSelect.innerHTML = toListHtml.toString();
            Dom.addClass(submitButton, 'hidden');
            if (Dom.hasClass(submitButton, 'active')) {
                Dom.removeClass(submitButton, 'active')
            }
        }

        //去服务器端取商品的信息，需要类目id，三个属性及其值的key-value对：  地区、面值、充值方式。
        function getPriceInfo() {
            priceSelect.innerHTML = '<span class="price-loading">正在查询价格，请稍候…</span>';
            formTelephone['item_id_num'].value = '';
            YAHOO.util.Get.script(
                getPriceUrl(),
                {
                    onSuccess: function () {
                        var result = __GetZoneResult_;
                        if (Lang.isNumber(result.price)) {
                            priceLabel.innerHTML = "价格：";
                            priceSelect.innerHTML = result.price + '元';
                            formTelephone['item_id_num'].value = Lang.trim(result.item_id_num);
                            //显示充值按钮
                            if (Dom.hasClass(submitButton, 'hidden')) {
                                Dom.removeClass(submitButton, 'hidden');
                            }
                        } else {
                            onGetPriceInfoError(result);
                            formTelephone['item_id_num'].value = result.item_id_num;
                        }
                    },
                    onFailure: function (o) {
                        onGetPriceInfoError(result);
                    },
                    charset: document.charset || document.characterSet
                }
            );
        }

        //获得价格区间
        function getPriceZoneInfo() {
            formTelephone['item_id_num'].value = '';
            var priceZoneValue;
            //获取所在地，面值等
            var reservePrice = getReservePrice();
            var catId = telISPSelect.value;

            //获得充值方式，不同的充值方式价格区间不一样
            var method = getMethodSelected();

            if (method == 0) {//直冲
                priceZoneValue = gFilters['common-ecard_item-' + reservePrice];
            } else if (method == 1) {//代充
                priceZoneValue = gFilters['common-delegator_fill-' + reservePrice];
            } else if (method == 2) {//自动发货
                priceZoneValue = gFilters['common-auto_post-' + reservePrice];
            }

            if (priceZoneValue != null && priceZoneValue != undefined) {
                var commaIndex = priceZoneValue.indexOf(',');
                var length = priceZoneValue.indexOf(']');
                if (commaIndex != -1) {
                    var priceStart = priceZoneValue.substring(1, commaIndex);
                    var priceEnd = priceZoneValue.substring(commaIndex + 1, length);
                    priceSelect.innerHTML = priceStart + '元-' + priceEnd + '元';
                }
            }
            //显示充值按钮
            if (Dom.hasClass(submitButton, 'hidden')) {
                Dom.removeClass(submitButton, 'hidden');
            }

            priceLabel.innerHTML = "价格：";
        }

        //增加刷新价格的监听事件
        Event.on('J_DenominationSelect', 'change', function (e) {
            //先清空价格
            var len = denominationRadioArr.length;
            priceSelect.innerHTML = '';
            //自动选中面额的其他选项
            for (var i = 0; i < len - 1; i++) {
                denominationRadioArr[i].getElementsByTagName('input')[0].checked = false;
                Dom.removeClass(denominationRadioArr[i], 'selected');
            }
            denominationRadioArr[len - 1].getElementsByTagName('input')[0].checked = true;
            Dom.addClass(denominationRadioArr[len - 1], 'selected');
            if (isPriceEnoughCondition()) {
                getPriceInfo();
            } else {
                getPriceZoneInfo();
            }
        });

        //改变充值方式时刷新价格
        var methodRadioArr = Dom.get('J_MethodBox').getElementsByTagName('label');
        Event.on(methodRadioArr, 'click', function (e) {
            priceSelect.innerHTML = '';
            var t = Event.getTarget(e);
            if (t.nodeName.toLowerCase() == 'input') {
                if (isPriceEnoughCondition()) {
                    getPriceInfo();
                } else {
                    getPriceZoneInfo();
                }
            }
        });

        //改变所在地,更新其他面值下拉框的选项,同时刷新价格或价格区间
        Event.on('J_TelZone', 'change', function (e) {
            priceSelect.innerHTML = '';
            if (isPriceEnoughCondition()) {
                getPriceInfo();
            } else {
                getPriceZoneInfo();
            }
            changeReserve();
        });
        //改变运营商,更新其他面值下拉框的选项,同时刷新价格或价格区间
        Event.on('J_TelISP', 'change', function (e) {
            priceSelect.innerHTML = '';
            if (isPriceEnoughCondition()) {
                getPriceInfo();
            } else {
                getPriceZoneInfo();
            }
            changeReserve();
        });

        //埋点log
        Event.on('J_SubmitButton', 'click', function (e) {

            //获取所在地，运营商等
            var suoshu = encodeURIComponent(encodeURIComponent(Dom.get('suoshu').value));
            var type = encodeURIComponent(encodeURIComponent(Dom.get('type').value));


            var telString = Dom.get('telString');


            var location = encodeURIComponent(encodeURIComponent(telZoneSelect.value));
            var catId = telISPSelect.value;

            var params = new StringBuffer();

            params.append('telString=' + telString.value);
            params.append('&start_suoshu=' + suoshu);
            params.append('&start_type=' + type);
            params.append('&now_suoshu=' + location);
            params.append('&now_type=' + catId);


            var rootUrl = 'http://tcc.taobao.com/cc/json/log_for_mobile.htm?';
            var url = rootUrl + params.toString();

            YAHOO.util.Get.script(
                url,
                {
                    onSuccess: function () {

                    },
                    onFailure: function (o) {

                    },
                    charset: document.charset || document.characterSet
                }
            );
        });


        //校验号码是否符合
        function commonValidateTel() {
            var val = telInput.value;
            if (val.match(CMCCPhoneNumberPattern) || val.match(CUCPhoneNumberPattern) || val.match(CommonPhoneNumberPattern)) {
                return true;
            }
            return false;
        }

        function isPriceEnoughCondition() {
            if (telZoneSelect.selectedIndex == 0 || telISPSelect.selectedIndex == 0) {
                return false;
            }
            if (!Dom.hasClass(belongResult, 'hidden') || !Dom.hasClass(selectZone, 'hidden')) {
                return true;
            }

            return false;
        }

        function validateItemId(value) {
            if (!Lang.isNull(value) && !Lang.isUndefined(value) && value != '' && value != '暂缺') {
                return true;
            }
            return false;
        }


    });
</script>

</body>
</html>
